package edu.gatech.aristotle.random.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;

import com.sun.corba.se.impl.javax.rmi.CORBA.Util;

import net.util.Debug;
import net.util.File_Handler;
/**
 * PASS: 0
 * FAIL: 1
 * XPASS, XFAIL: 0
 * Others: X
 * @author paul
 *
 */
public class GCC_RandomTestCaseConverter {
	public static void main(String args[]) throws IOException{
		String filePath	= "gcc_testing_result\\rd_gfortran.txt";
		
		GCC_RandomTestCaseConverter gc			= new GCC_RandomTestCaseConverter();
		ArrayList<Integer> testResultArray		= gc.buildResultArray(filePath);
		
		Debug.println( testResultArray );
	}

	final private String PASS	= "PASS:";
	final private String FAIL	= "FAIL:";
	final private String XFAIL	= "XFAIL:";
	final private String XPASS	= "XPASS:";
	
	public ArrayList<Integer> buildResultArray(String filePath) throws IOException{
		ArrayList<Integer> resultArray	= new ArrayList<Integer> ();
		
		BufferedReader bufferReader = File_Handler.createBufferReader( filePath );
		String oneLine;
		while (true){
			oneLine	= bufferReader.readLine(); // pass the header of the first line
			
			if (oneLine == null) break;
			
			
			if 
			(
				oneLine.startsWith( PASS )
					||
				oneLine.startsWith( XFAIL )
					||
				oneLine.startsWith( XPASS )
			){
				resultArray.add( 0 );
			}else if (oneLine.trim().startsWith( FAIL )){
				Debug.println( oneLine );
				resultArray.add( 1 );
			}			
		}		
		
		return resultArray;
	}
}
